//
//  DYIdentification.m
//  Stormbills
//
//  Created by 帝云科技 on 2018/7/9.
//  Copyright © 2018年 帝云科技. All rights reserved.
//
#import "DYIdentification.h"
#import "ShowAPIRequest.h"

static NSString *const showAppid = @"69276";
static NSString *const showAppSecret = @"8a8dad162b2f4095b4672d834d1625ba";
static NSString *const _url_showApi_id = @"http://route.showapi.com/1429-1";
static NSString *const _url_showApi_bank = @"http://route.showapi.com/1520-2";

@implementation DYIdentification

+ (ShowAPIRequest *)request
{
    return [[ShowAPIRequest alloc] initWithAppid:showAppid andSign:showAppSecret];
}

+ (void)identificationIdCardImage:(UIImage *)image type:(NSString *)type completion:(DYIdentificationBlock)completion
{
    NSData *data = UIImageJPEGRepresentation(image, 0.5f);
    NSString *dataString = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    NSDictionary *param = @{@"imgData": dataString, @"type": type};
    [[self request] post:_url_showApi_id
                 timeout:20000
                  params:param
          withCompletion:^(NSDictionary<NSString *,id> *result) {
              if (completion) {
                  completion(result);
              }
          }];
}

+ (void)identificationBankImage:(UIImage *)image completion:(DYIdentificationBlock)completion
{
    NSData *data = UIImageJPEGRepresentation(image, 0.5f);
    NSString *dataString = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    NSDictionary *param = @{@"imgData": dataString};
    [[self request] post:_url_showApi_bank
                 timeout:20000
                  params:param
          withCompletion:^(NSDictionary<NSString *,id> *result) {
              if (completion) {
                  completion(result);
              }
          }];
}



@end
